package com.lc.base.controller;

import com.lc.base.ResultBean;
import com.lc.framework.controller.BaseController;
import com.lc.page.PageReq;
import com.lc.base.entities.TDemo;
import com.lc.base.service.ITDemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 测试表 前端控制器
 * </p>
 *
 * @author jsbj
 * @since 2022-03-02
 */
@RestController
@Api(value = "demo接口",description = "demo接口")
@RequestMapping("/t-demo")
public class TDemoController extends BaseController {

    @Autowired
    private ITDemoService tDemoService;

    @ApiOperation("查询列表")
    @PostMapping("/list")
    public ResultBean<PageReq> search(@RequestBody TDemo tDemo) {
        return new ResultBean<PageReq>(getPage(tDemoService.getList(tDemo)));
    }

    @ApiOperation("根据条件查询")
    @PostMapping("/getBycondition")
    public ResultBean<List<TDemo>> getBycondition(@RequestBody TDemo tDemo) {
        return new ResultBean<List<TDemo>>(tDemoService.getBycondition(tDemo));
    }

    @ApiOperation("新增数据")
    @PostMapping("/addData")
    public ResultBean<Integer> addData(TDemo tDemo) {
        return new ResultBean<Integer>(tDemoService.addData(tDemo));
    }

    @ApiOperation("修改数据")
    @PostMapping("/modifyData")
    public ResultBean<Integer> modifyData(TDemo tDemo) {
        return new ResultBean<Integer>(tDemoService.modifyData(tDemo));
    }

    @ApiOperation("删除数据")
    @PostMapping("/deleteData/{id}")
    public ResultBean<Integer> deleteData(@PathVariable("id") Integer id) {
        return new ResultBean<Integer>(tDemoService.deleteData(id));
    }

}

